<template>
  <el-container >
    <el-header style="padding: 0;height: 100px;">
      <app-header/>
    </el-header>
    <el-container style="display: flex;">
      <el-aside style="width: 200px;overflow: hidden">
        <app-nav/>
      </el-aside>
      <el-main style="flex: 1 ; min-height: 90vh; background-color: #EAB6AB;">
        <!--<app-bread-crubms :data="this.routeMatched"></app-bread-crubms>-->
        <div class="content-wrapper">
          <router-view/>
        </div>
        <el-alert
          style="position: fixed; top: 50px; left: 50%; width: 300px; z-index: 9999;"
          :title="error || ''"
          type="error"
          show-icon
          center
          v-show="error"
          @close="clearError">
        </el-alert>
        <el-alert
          style="position: fixed; top: 50px; left: 50%; width: 300px; z-index: 9999;"
          :title="info || ''"
          type="success"
          show-icon
          center
          v-show="info"
          @close="clearInfo">
        </el-alert>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
  import AppHeader from '@/components/AppHeader'
  import AppNav from '@/components/AppNav'
  import AppBreadCrumbs from '@/components/AppBreadCrumbs'
  import {mapGetters, mapMutations} from 'vuex'

  export default {
    name: 'AppLayout',
    components: {
      'app-header': AppHeader,
      'app-nav': AppNav,
      'app-bread-crubms':AppBreadCrumbs,
    },
    data(){
      return {
        routeMatched:[]
      }
    },

    mounted() {
      this.routeMatched = this.$route.matched
    },
    updated(){
      this.routeMatched = this.$route.matched
    },

    methods: mapMutations(['clearInfo', 'clearError']),

    computed: {
      currentUser() {
        let json = window.sessionStorage.getItem('currentUserAdmin')
        return json && JSON.parse(json);
      },
      ...mapGetters(['info', 'error'])
    }
  }
</script>

<style lang="scss" scoped>
  .content-wrapper {
    background-color: #EAB6AB;
    padding: 20px;
    border-radius: 8px;
    margin-top: 1em;
  }
</style>
